package com.lys.eduservice.controller;


import com.lys.commonutils.R;
import com.lys.eduservice.entity.subject.OneSubject;
import com.lys.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author lys
 * @since 2022-06-28
 */
@RestController
@RequestMapping("/eduservice/edusubject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

    //添加课程分类
    //获取上传过来文件，把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }

    //查询课程分类(树形)
    @GetMapping("/getAllSubject")
    public R getAllSubject(){
        List<OneSubject> oneSubjectList = eduSubjectService.getAllOneTwoSubject();
        return R.ok().data("oneSubjectList",oneSubjectList);
    }
}

